package gevis.common;

public class Debug 
{
	private final static String Make()
	{
		return Make(0);
	}
	
	private final static String Make(int downlevel)
	{
		StackTraceElement myCaller = null;
		StackTraceElement[] ste = Thread.currentThread().getStackTrace();
		int startpos = downlevel+4;
		if(startpos >= ste.length) startpos = ste.length - 1;
		for(int i=startpos;i<startpos+10;i++)
		{
			if(!(ste[i].getClassName().equals("Debug")))
			{
				myCaller = Thread.currentThread().getStackTrace()[i];
				break;
			}
		}
		if(myCaller == null) return null;
		StringBuilder sb = new StringBuilder();
		sb.append(myCaller.getClassName());
		sb.append(".");
		sb.append(myCaller.getMethodName());
		sb.append(" [");
		sb.append(myCaller.getLineNumber());
		sb.append("]");
		return sb.toString();
	}
	
	public static void funcStart()
	{
		System.out.println("===== " + Make() + " Start ");
	}
	
	public static void funcEnd()
	{
		System.out.println("===== " + Make() + " End \n");
	}
	
	public static void print(String msg)
	{
		System.out.println(msg);
	}
}
